import React, { Component } from 'react'
import Son from './Son'
import PubSub from 'pubsub-js'
export default class Far extends Component {
  componentDidMount() {
    // 订阅话题
    PubSub.subscribe('richFemale', (topic, data) => {
      console.log('far组件接收到了富婆的话题', topic, data)
    })
  }
  render() {
    return (
      <div>
        Far,
        <button
          onClick={() => {
            PubSub.publish('car', '劳斯莱斯')
          }}
        >
          发布汽车话题
        </button>
        <Son></Son>
      </div>
    )
  }
}
